import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router';
import NProgress from 'nprogress'; // progress bar
import 'nprogress/nprogress.css';
import {
  REDIRECT_ROUTE_NAME,
  NOT_FOUND_ROUTE_NAME,
  HOME_ROUTE_NAME,
} from './constant';

NProgress.configure({ showSpinner: false }); // NProgress Configuration

export const HOME_ROUTE: RouteRecordRaw = {
  path: '/',
  name: HOME_ROUTE_NAME,
  component: () => import('@/views/home/index.vue'),
};

export const REDIRECT_ROUTE: RouteRecordRaw = {
  path: '/redirect/:path',
  name: REDIRECT_ROUTE_NAME,
  component: import('@/views/redirect/index.vue'),
};

export const NOT_FOUND_ROUTE: RouteRecordRaw = {
  path: '/:pathMatch(.*)*',
  name: NOT_FOUND_ROUTE_NAME,
  component: () => import('@/views/not-found/index.vue'),
};

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [HOME_ROUTE, REDIRECT_ROUTE, NOT_FOUND_ROUTE],
});

export default router;
